<?php
/*
# $Id$
*/

// Class paths
BuanAutoLoader::addClassPath(dirname(dirname(__FILE__)).'/lib');

// Remove any previously created databases
$dbInfo = Database::getConnectionInfo('default');
$dbFile = preg_replace("/^sqlite:(.*?)$/i", "$1", $dbInfo['dsn']);
if(file_exists($dbFile)) {
	unlink($dbFile);
}

// Create test database
$schema = new SqlDumpIterator(file_get_contents(Config::get('app.dir.config').'/db-schema.sql'));
foreach($schema as $query) {
	try {
		$stmt = ModelManager::sqlQuery($query);
	}
	catch(Exception $e) {
		die($e->getMessage());
	}
}
?>